// 删除重复项
/**
 * @param {number[]} nums
 * @return {number}
 */
  /*var removeDuplicates = function(nums) {
let i=0;
 while(i<nums.length)
 { 
     if(i>0&&nums[i-1]==nums[i]) {
        nums.splice(i,1);
      //  console.log(nums)
     }
     else
     i++;
 }
 
 return nums.length
};*/

/**
 * @param {number[]} nums
 * @return {number}
 */
 var removeDuplicates = function(nums) {
    /*if (nums.length <= 1) return nums.length;
    let lo = 0, hi = 0;
    while (hi < nums.length) {
      while (nums[lo] === nums[hi] && hi < nums.length) hi++;
      if (nums[lo] !== nums[hi] && hi < nums.length) {
        lo++;
        nums[lo] = nums[hi];
      }
      hi++;
    }
    return lo + 1;
    */
    let n=nums.length
    let i=0;j=1;
    while(j<n) {
        if(nums[i]!==nums[j]) {
            i++;
            nums[i]=nums[j]
        }
        j++;
    }
    return i+1;
  };
  
  